package com.syg.Listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

/**
 * session绑定(其实就是:把一个对象放入session)
 */
public class _07_Users_BindingListener implements HttpSessionBindingListener{

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public String id;//用户编号
    public String name;//用户姓名
    public String age;//用户年龄

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
        logger.info("valueBound()==>实现HttpSessionBindingListener接口的对象放入了session当中");
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("valueUnbound()==>从session当中移除实现HttpSessionBindingListener接口的对象");
    }
}
